<template>
  <div class="login">
    <div class="login_main">
      <div class="user_img">
        <img src="../../static/imgs/userPic.png" style="width: 130px;  height: 130px;">
      </div>
      <div class="w12 user_info">
        <div class="user_input mt30">
          <b class="w02">账号</b>
          <nut-textinput
            v-model="account"
            class="w10"
            placeholder="请输入账号"
            type="text"
          />
        </div>
        <div class="user_input">
          <b class="w02">密码</b>
          <nut-textinput
            v-model="password"
            class="w10"
            placeholder="请输入密码"
            type="password"
          />
        </div>
        <div class="change_login fr mt10 mb10"><h2><a>短信登陆</a></h2></div>
      </div>
      <nut-button class="mt10 jl_button" block shape="circle" @click="login">登录</nut-button>
    </div>
    <jl-footer style="border: 0px!important;">
      <div class="login_bq">
        <img src="../../static/imgs/login_bq_zh.png">
      </div>
    </jl-footer>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        loading: null,
        account: '',
        password: ''
      }
    },
    methods: {
      login() {
        this.loading = this.$toast.loading();
        this.$api.user.login({
          CZY01: this.account,
          CZY02: this.password
        }).then(v => {
          this.loading.hide();
          if (v.data.STATE == 1) {
            let userInfo = v.data.userInfo;
            let sessionid = v.data.sessionid;

            let userData = {};
            userData["PCRM_CZY01"] = userInfo["USERID"];
            userData["PCRM_CZY02"] = userInfo["CZY01"];
            userData["PCRM_CZY03"] = userInfo["CZY03"];
            userData["PCRM_CZY06"] = userInfo["CZY06"];
            userData["PCRM_GW01"] = userInfo["GW01"];
            userData["PCRM_GW02"] = userInfo["GW02"];
            userData["PCRM_BM01"] = userInfo["BM01"];
            userData["PCRM_BM02"] = userInfo["BM02"];
            userData["PCRM_BM03"] = userInfo["BM03"];
            userData["PCRM_BM_BM01"] = userInfo["BM_BM01"];
            userData["PCRM_GSXX01"] = userInfo["GSXX01"];

            userData["SCM_BM01"] = userInfo["SCM_BM01"];
            userData["SCM_RYXX08"] = $Utils.isNull(userInfo["RYXX08"]) ? [] : userInfo["RYXX08"].split(";");
            userData["SCM_RYXX23"] = userInfo["RYXX23"];
            userData["SCM_JSSY01"] = userInfo["JSSY01"];
            userData["SCM_BBBZ01"] = userInfo["BBBZ01"];
            userData["SCM_BZ04"] = userInfo["BZ04"];
            userData["PCRM_WLDW01"] = userInfo["WLDW01"];
            userData["PCRM_CZY10"] = userInfo["CZY10"];
            userData["FORM_MRCD"] = userInfo["MRCD"];//默认菜单
            userData["FORM_DCBJ"] = userInfo["DCBJ"];//导出标记
            userData["skbj"] = userInfo["SKBJ"];//受控标记
            userData["SessionID"] = userInfo["SessionID"];

            userData["PersonID"] = userInfo["CZY01"];
            userData["CompanyID"] = userInfo["GSXX01"];

            localStorage.setItem('userInfo', JSON.stringify(userData));
            localStorage.setItem('SessionId', sessionid);
            //this.$natives.UpdOpenId()
            this.$router.replace({name: 'agent'});
          } else {
            $Utils.toast({message: '账号密码错误'})
          }
        }).catch(e => {
          console.log(e)
          this.loading.hide();
        })
      }
    }
  }

</script>

<style scoped>

  .login {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 10;
    left: 0px;
    top: 0px;
    background: #fff;
  }

  .login .login_main {
    float: left;
    width: 86%;
    margin-left: 7%;
    padding-top: 20%;
  }

  .login .login_main .user_img {
    float: left;
    width: 70%;
    text-align: center;
    margin: 0 0 0 15%;
  }

  .login .login_main .user_img img {
  }

  .login .login_main .user_info {
  }

  .user_input {
    height: 40px;
    margin-top: 20px;
  }

  .user_input b {
    line-height: 40px;
    font-weight: 500;
    font-size: 1.9rem;
    float: left;
    width: 25%;
  }

  .user_input input {
    height: 39px;
    border: 0px;
    font-size: 18px;
    float: left;
    width: 75%;
  }

  .user_input i {
    float: left;
    width: 10%;
    text-align: right;
    height: 40px;
    line-height: 40px;
    color: #aaa;
    font-size: 20px;
  }

  .user_input button {
    border: 1px solid #000;
    border-radius: 3px;
    font-size: 1.3rem;
    position: absolute;
    right: 0px;
    padding: 6px 0;
    width: 70px;
    text-align: center;
    background: #fff;
    top: 5px;
  }

  .login_bq {
    float: left;
    width: 100%;
    text-align: center;
    margin: 10px 0;
  }

  .login .logo {
    width: 85px;
    height: 85px;
    margin: 50px auto;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #e4e4e4;
  }

  .login .logo > img {
    width: 100%;
  }

  .login .thdLogin {
    position: absolute;
    width: 100%;
    bottom: 0px;
    padding: 5px 15px;
  }

  .login .thdLogin h3 {
    height: 30px;
    line-height: 30px;
    font-weight: 100;
    font-size: 12px;
    color: #ccc;
  }

  .login .thdLogin i {
    font-size: 1.2rem !important;
  }
</style>
